/*
 * Timer_Interrupts.c
 *
 *  Created on: 09/03/2013
 *      Author: Bowmer
 */


#include "inc/hw_types.h"
#include "inc/lm4f120h5qr.h"
#include "driverlib/gpio.h"

#include "RangeFinder_Switch.h"

extern volatile unsigned int rangeFinderIndex;

void TIMER5_A_INT(void){
	unsigned long TimerStatus;

	// Get the interrupt status
	TimerStatus = WTIMER5_MIS_R;

	// Clear the asserted interrupts
	WTIMER5_ICR_R = TimerStatus;

	Call_Rangefinder(rangeFinderIndex++);
	if(rangeFinderIndex > 3) rangeFinderIndex = 0;

	//toggle so we can see when the interrupt is being triggered in the Saleae Logic Analyser
	GPIO_PORTB_DATA_R |= GPIO_PIN_0;
	GPIO_PORTB_DATA_R &= !GPIO_PIN_0;

}

void TIMER0_A_INT(void){
	unsigned long TimerStatus;

	// Get the interrupt status
	TimerStatus = WTIMER0_MIS_R;

	// Clear the asserted interrupts
	WTIMER0_ICR_R = TimerStatus;

	GPIO_PORTC_DATA_R &= ~GPIO_PIN_4;
}

void TIMER1_A_INT(void){
	unsigned long TimerStatus;

	// Get the interrupt status
	TimerStatus = WTIMER1_MIS_R;

	// Clear the asserted interrupts
	WTIMER1_ICR_R = TimerStatus;

	GPIO_PORTC_DATA_R &= ~GPIO_PIN_6;
}
void TIMER2_A_INT(void){
	unsigned long TimerStatus;

	// Get the interrupt status
	TimerStatus = WTIMER2_MIS_R;

	// Clear the asserted interrupts
	WTIMER2_ICR_R = TimerStatus;

	GPIO_PORTD_DATA_R &= ~GPIO_PIN_0;
}

void TIMER3_A_INT(void){
	unsigned long TimerStatus;

	// Get the interrupt status
	TimerStatus = WTIMER3_MIS_R;

	// Clear the asserted interrupts
	WTIMER3_ICR_R = TimerStatus;

	GPIO_PORTD_DATA_R &= ~GPIO_PIN_2;
}
